{include file='pub/header'/}
<title>积分设置</title>
</head>
<body>
<div class="page-container">
	<form class="form form-horizontal" action="{:url('Marketing/scoreSet')}" method="post">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>每日签到赠送积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.day_score}" placeholder="" id="day_score" name="day_score">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否开启签到赠送积分：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<label for="is_day_score1"><input type="radio" id="is_day_score1" name="is_day_score" value="1"/>开启</label>
				<label for="is_day_score2"><input type="radio" id="is_day_score2" name="is_day_score" value="0"/>关闭</label>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>消费返积分比例：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.ratio_score}" placeholder="" id="ratio_score" name="ratio_score">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否开启消费返积分比例：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<label for="is_ratio_score1"><input type="radio" id="is_ratio_score1" name="is_ratio_score" value="1"/>开启</label>
				<label for="is_ratio_score2"><input type="radio" id="is_ratio_score2" name="is_ratio_score" value="0"/>关闭</label>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-secondary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存设置</button>
			</div>
		</div>
	</form>
</div>
{include file="pub/footer"/}
<script type="text/javascript">
$(function(){
    if("{$data.is_day_score}" == 1){
        $("#is_day_score1").prop('checked', true);
    }else{
        $("#is_day_score2").prop('checked', true);
    }
    if("{$data.is_ratio_score}" == 1){
        $("#is_ratio_score1").prop('checked', true);
    }else{
        $("#is_ratio_score2").prop('checked', true);
    }
    $("form").validate({
		rules:{
		    day_score: {
		        required:true
			},
			is_day_score:{
		        required:true
			},
			ratio_score:{
		        required:true
			},
			is_ratio_score:{
		        required:true
			}
		},
		messages:{
            day_score:{
                required:'签到积分不能为空'
            },
            is_day_score:{
                required:'请选择是否开启签到送积分'
            },
            ratio_score:{
                required:'消费返积分比例'
            },
            is_ratio_score:{
                required:'请选择是否开启消费返积分功能'
            }
		},
        onkeyup:false,
        focusCleanup:true,
        success: 'valid',
		submitHandler:function(form){
            $(form).ajaxSubmit(function(res){
                if(res.code == 1){
                    location.reload();
                }else{
                    layer.alert(res.msg);
                }
            });
		}
	});
});
</script>
</body>
</html>